<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>计算器</title>
</head>
<body>
<input type="text" id="num1">
<select name="" id="op">
    <option value="0">请选择</option>
    <option value="1">+</option>
    <option value="2">-</option>
    <option value="3">*</option>
    <option value="4">/</option>
</select>
<input type="text" id="num2">
<button id="cal">计算</button>
<div id="res">

</div>
</body>
</html>
<script>
    var oButton = document.getElementById('cal')
    oButton.onclick = function() {
        var oNum1 = document.getElementById('num1')
        var oNum2 = document.getElementById('num2')
        var oSelect = document.getElementById('op')
        num1 = oNum1.value
        num2 = oNum2.value
        op = oSelect.value
        num1 = Number(num1)
        num2 = Number(num2)
        if (op == '0'){
           alert("请选择运算符")
        } else if (op == '1'){
           res = num1 + num2
        }  else if (op == '2'){
           res = num1 - num2
        }  else if (op == '3'){
           res = num1 * num2
        }  else if (op == '4'){
           res = num1 / num2
        }
        var oDiv = document.getElementById('res')
        oDiv.innerText = ''+ res
    }
</script>